// import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';
import 'package:transparent_image/transparent_image.dart';

class ImagePage extends StatefulWidget {
  final Map<String, dynamic> arguments;
  ImagePage({Key key, this.arguments}) : super(key: key);

  @override
  _ImagePageState createState() => _ImagePageState();
}

class _ImagePageState extends State<ImagePage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('ImagePage'),
      ),
      body: ListView(
        children: <Widget>[
          ListTile(  
            title: Text('''加载网络图片'''),
            subtitle: Column(
              children: <Widget>[
                Container(
                  height: 160.0,
                  child: Row(
                    mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                    children: <Widget>[
                      Image.network('https://www.devio.org/img/avatar.png'),
                      Image.network('http://www.zlcool.com/d/file/2014/06/09/d16e27e737bd8fe34458abc218fe1022.gif'),
                    ],
                  ),
                )
              ],
            ),
          ),
          Divider(height: 1.0),
          ListTile(
            title: Text('''加载静态图片'''),
            subtitle: Column(
              children: <Widget>[
                // 以下两个方法等效
                Image.asset('resources/images/components/user/upgrade_member.png', height: 80.0),
                Image(
                  image: AssetImage('resources/images/components/user/upgrade_member.png'),
                  height: 60,
                  width: 60,
                  fit: BoxFit.cover,
                ),
              ],
            ),
          ),
          Divider(height: 1.0),
          ListTile(
            title: Text('''memoryNetwork'''),
            subtitle: Column(
              children: <Widget>[
                Container(
                  width: 200.0,
                  height: 200.0,
                  child: Stack(
                    alignment: Alignment.center,
                    children: <Widget>[
                      Center(child: CircularProgressIndicator()),
                      Center(
                        child: FadeInImage.memoryNetwork(
                          placeholder: kTransparentImage,
                          image: 'https://www.devio.org/img/avatar.png',
                        ),
                      ),
                    ],
                  ),
                ),
              ],
            ),
          ),
          Divider(height: 1.0),
          ListTile(
            title: Text('''assetNetwork'''),
            subtitle: Column(
              children: <Widget>[
                Container(
                  width: 300.0,
                  height: 200.0,
                  child: FadeInImage.assetNetwork(
                    placeholder: 'resources/images/others/image_placeholder.jpg',
                    image: 'http://pic1.win4000.com/wallpaper/2/542109ab8b428.jpg',
                    fit: BoxFit.cover,
                  ),
                )
              ],
            ),
          ),
          Divider(height: 1.0),
          ListTile(
            title: Text('''CachedNetworkImage'''),
            subtitle: Column(
              children: <Widget>[
                Text('引入 cached_network_image 无法 pod install 后期再看'),
                Container(
                  width: 300.0,
                  height: 200.0,
                  // TODO: 引入 cached_network_image 无法 pod install 后期再看
                  // child: CachedNetworkImage(imageUrl: 'http://attach.bbs.miui.com/forum/201311/01/215828tpmddz2d2bfcz5pk.jpg'),
                )
              ],
            ),
          ),
          Divider(height: 1.0),
        ],
      ),
    );
  }
}
